<?php
if(!defined('PATH')) exit();
?>
<?=$this->archez->showMsg('Welcome to your account management page, <b>' . $account->getCustomField('nickname') . '</b>.', 'notice')?>
<br />
<table border="0" cellpadding="8" cellspacing="1" width="100%">
<tr class="head"><td colspan="2"><b>Account Information</b></td></tr>
<?php
$key = (!$account->getRecoveryKey()) ? '<span style="color:red;">unregistered</span><span style="float:right;"><a href="' . PATH . '/account/recovery/">get key</a></span>' : '<span style="color:green;">registered</span>';
?>
<tr><td width="25%">Recovery key:</td><td><?=$key?></td></tr>
<?php
$premdays = $account->getPremDays();
$status = '<span style="color:red;">free account</span>';
if ($premdays == 1) {
	$status = '<span style="color:green;">premium account</span><span style="float:right;"><small>1 day left</small></span>';
} else if ($premdays > 1) {
	$status = '<span style="color:green;">premium account</span><span style="float:right;"><small>'.$premdays.' days left</small></span>';
}
?>
<tr><td>Status:</td><td><?=$status?></td></tr>
<tr><td>Nickname:</td><td><?=$account->getCustomField('nickname')?></td></tr>
<tr><td>E-mail:</td><td><?=$account->getCustomField('email')?></td></tr>
<tr><td>Created:</td><td><?=date($this->config['website']['date_format'], $account->getCustomField('created'))?></td></tr>
<tr><td>Last login:</td><td><?=date($this->config['website']['date_format'], $account->getCustomField('page_lastday'))?></td></tr>
</table>
<br/>
<table border="0" cellpadding="8" cellspacing="1" width="100%">
<tr class="head"><td colspan="2"><b>Options</b></td></tr>
<tr><td width="5%"><a href="<?=PATH?>/account/change_password/"><img src="<?=PATH?>/media/images/change_password.png" title="change password" /></a></td><td><a href="<?=PATH?>/account/change_password/">Change password</a></td></tr>
<?php
$time = $account->getCustomField('email_new_time');
if ($time > time()) {
?>
<tr><td width="5%"><a href="<?=PATH?>/account/change_email/"><img src="<?=PATH?>/media/images/change_email.png" title="change email" /></a></td><td><a href="<?=PATH?>/account/change_email/">Activate or cancel new e-mail: <b><?=$account->getCustomField('email_new')?></b> (possible at <?=date($this->config['website']['date_format'], $time)?>)</a></td></tr>
<?php
} else {
?>
<tr><td width="5%"><a href="<?=PATH?>/account/change_email/"><img src="<?=PATH?>/media/images/change_email.png" title="change email" /></a></td><td><a href="<?=PATH?>/account/change_email/">Change e-mail</a></td></tr>
<?php
}
if ($account->getRecoveryKey()) {
?>
<tr><td width="5%"><a href="<?=PATH?>/account/regenerate_recovery/"><img src="<?=PATH?>/media/images/regenerate_recovery.gif" title="regenerate recovery" /></a></td><td><a href="<?=PATH?>/account/regenerate_recovery/">Regenerate recovery key</a></td></tr>
<?php
}
if ($this->config['website']['store']['status']) {
?>
<tr><td width="5%"><a href="<?=PATH?>/store/record/"><img src="<?=PATH?>/media/images/store.png" title="regenerate recovery" /></a></td><td><a href="<?=PATH?>/store/record/">Store Transactions</a></td></tr>
<?php
}
?>
</table>
<?php
$rlname = (!$account->getRLName()) ? '<a href="' . PATH . '/account/personal/">click here to set your name</a>' : strip_tags($account->getRLName());
$location = (!$account->getLocation()) ? '<a href="' . PATH . '/account/personal/">click here to set your location</a>' : strip_tags($account->getLocation());

if ($account->getRLName() or $account->getLocation())
{
	$change = '<span style="float:right;"><a href="' . PATH . '/account/personal/"><img src="' . PATH . '/media/images/edit.png" title="change information" alt="change" /></a></span>';
}
else
{
	$change = '';
}
?>
<br /><table border="0" cellpadding="8" cellspacing="1" width="100%">
<tr class="head"><td colspan="2"><b>Personal</b><?=$change?></td></tr>
<tr><td width="20%">Name:</td><td><?=$rlname?></td></tr>
<tr><td width="20%">Location:</td><td><?=$location?></td></tr>
</table>
<br /><table border="0" cellpadding="8" cellspacing="1" width="100%">
<tr class="head"><td colspan="4"><b>Characters</b></td></tr>
<tr class="bold"><td width="50%">Name</td><td width="15%">Level</td><td width="25%">Vocation</td><td>Status</td></tr>
<?php
$characters = $account->getPlayersList();
$characters->orderBy('name');

foreach($characters as $row)
{
	if ($row->isOnline())
	{
		$row_status = '<span style="color:green;">online</span>';
	}
	else
	{
		$row_status = '<span style="color:red;">offline</span>';
	}
	
	$row_hidden = ($row->getHideChar()) ? '<span style="color:red;font-size:10px;float:right;">HIDDEN</span>' : '';
	
	if (!$row->isDeleted()) {
?>
	<tr><td><a href="<?=PATH?>/search/check/<?=urlencode(strtolower($row->getName()))?>/"><?=$row->getName() . '</a>' . $row_hidden?></td><td><?=$row->getLevel()?></td><td><?=$this->config['server']['professions'][$row->getPromotion()][$row->getVocation()]?></td><td><?=$row_status?></td></tr>
<?php
	}
}
?>
</table>
<br /><table border="0" cellpadding="8" cellspacing="1" width="100%">
<tr class="head"><td colspan="2"><b>Options</b></td></tr>
<tr><td width="5%"><a href="<?=PATH?>/account/character/create/"><img src="<?=PATH?>/media/images/add.png" title="create new character" alt="create" /></a></td><td><a href="<?=PATH?>/account/character/create/">Create new character</a></td></tr>
<tr><td width="5%"><a href="<?=PATH?>/account/character/edit/"><img src="<?=PATH?>/media/images/character_edit.png" title="edit character" alt="edit" /></a></td><td><a href="<?=PATH?>/account/character/edit/">Edit character</a></td></tr>
<tr><td width="5%"><a href="<?=PATH?>/account/character/delete/"><img src="<?=PATH?>/media/images/character_delete.png" title="delete character" alt="delete" /></a></td><td><a href="<?=PATH?>/account/character/delete/">Delete character</a></td></tr>
</table>